import React from 'react';
import {inject, observer} from 'mobx-react';
import {Spin, Button, Modal, Radio, Tooltip, Row, Col, message, Popover} from 'antd';
import * as Util from '../../../util/Util';
import AccessViewFb from './AccessViewFb';
import AccessViewTable from './AccessViewTable';
import LoadLogs from '../../../public/loadlog/loadLogs';
import {
    WeaNewScroll,
    WeaTab,
    WeaPopoverHrm,
    WeaTools,
    WeaTag,
    WeaRichText,
    WeaReqTop,
    WeaTop,
    WeaSearchGroup,
    WeaLocaleProvider,
    WeaFormItem,
    WeaBrowser,
    WeaDateGroup,
    WeaInput,
    WeaSelect,
    WeaRightMenu,
    WeaDialog
} from 'ecCom';

const RadioGroup = Radio.Group;
const RadioButton = Radio.Button;
const toJS = mobx.toJS;
const getLabel = WeaLocaleProvider.getLabel;

/**
 * 绩效评分
 */
@inject("accessViewStore")
@observer
export default class AccessView extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            _height: Util.getCurrentHeight(),
            morename: '',
            moretitle: '',
            tabkey: '0',//评分人tab项值
        }
    }

    componentWillMount() {//一些初始化请求
        const {accessViewStore} = this.props;
        let scoreid = Util.getParams("scoreid");
        let year = Util.getParams("year");
        let type1 = Util.getParams("type1");
        let type2 = Util.getParams("type2");
        let resourceid = Util.getParams("resourceid");
        accessViewStore.getDateList();
        this.getAccessView(scoreid, resourceid, year, type1, type2);
    }

    componentDidMount() {
        this.setState({
            morename: getLabel('509315', '显示所有'),
            moretitle: getLabel('509061', '显示包括查看在内的所有日志记录')
        })
    }

    render() {
        const {_height, moretitle, morename, tabkey} = this.state;
        const {accessViewStore} = this.props;
        const {
            tableHeader, yeardata, nowseason, nowyear, msg, nowmonth, loading, cstatus, ccolor,
            pesronstr, titlename, tabs, type1, type2, scoreid, canlog, logList, total, isplan, resourcename, resourceid, linkUrlList,
            datalist, itemcount, agentmessage
        } = accessViewStore;
        if (msg == "noinfo") {
            return Util.renderAlertPage('<span style="color:red">' + getLabel('508609', '您暂时无权限查看此数据') + '</span>','','','', this.props.ecId || '');
        }
        let link = "/spa/workrelate/static/index.html#/main/workrelate/performance/accessView";
        if (scoreid) {
            link = link + '?scoreid=' + scoreid;
        } else {
            link = link + '?resourceid=' + resourceid + "&year=" + nowyear + "&type1=" + type1 + "&type2=" + type2;
        }
        const collectParams = {
            favname: titlename,
            favouritetype: "5",
            link,
            importantlevel: 1,
        }

        //判断显示模式，true表示新的模式
        let showtype = false;
        //若只有一个人评分，默认显示旧的展现模式
        if (tableHeader && tableHeader.length > 1) {
            showtype = datalist.some((item, index) => index < itemcount && item.userid);
        }

        const topTab = tableHeader.map(item => {
            return {
                title: item.title,
                viewcondition: item.index
            }
        });
        let monthdata = [
            {label: '1', value: getLabel(25825, '1月')},
            {label: '2', value: getLabel(25826, '2月')},
            {label: '3', value: getLabel(25827, '3月')},
            {label: '4', value: getLabel(25828, '4月')},
            {label: '5', value: getLabel(25829, '5月')},
            {label: '6', value: getLabel(25830, '6月')},
            {label: '7', value: getLabel(25831, '7月')},
            {label: '8', value: getLabel(25832, '8月')},
            {label: '9', value: getLabel(25833, '9月')},
            {label: '10', value: getLabel(25834, '10月')},
            {label: '11', value: getLabel(25835, '11月')},
            {label: '12', value: getLabel(25836, '12月')}
        ];
        let seasondata = [
            {label: '1', value: getLabel(509092, '1季度')},
            {label: '2', value: getLabel(509093, '2季度')},
            {label: '3', value: getLabel(509094, '3季度')},
            {label: '4', value: getLabel(509095, '4季度')}
        ];
        return (
            <div className="wea-workrelate-perfor-accessview" style={{height: _height}}>
                <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@ebx6rf`} spinning={loading}>
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@nn3ad0`} datas={this.getRightButton(1)} collectParams={collectParams} showUrlItem={false}
                                  style={{height: '100%'}}>
                        {agentmessage &&
                        <div style={{background: '#fffccb', 'line-height': '32px', 'padding-left': '10px'}}>
                            <i style={{background: '#fff', color: '#ffaa00', borderRadius: '50%', marginRight: '10px'}}
                               className="icon-coms-Prompt"/>
                            <span dangerouslySetInnerHTML={{__html: agentmessage}}/>
                        </div>}
                        <WeaReqTop ecId={`${this && this.props && this.props.ecId || ''}_WeaReqTop@cwfbw0`}
                            title={titlename}
                            icon={<i className='icon-coms-implement'/>}
                            iconBgcolor='rgb(150, 53, 138)'
                            tabDatas={toJS(tabs)}
                            selectedKey={type1}
                            buttons={this.getRightButton()}
                            showDropIcon={false}
                            //dropMenuDatas = {this.getRightButton(1)}
                            onChange={(key) => this.onReqTop(key)}/>
                        <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@l5p5ki`}/>
                        <div className="accessview-baseinfo">
                            <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@nmxzk9`} options={yeardata} value={nowyear} viewAttr={2}
                                       style={{width: 80, marginRight: 10}} onChange={(v) => this.yearChange(v)}/>
                            {type1 == 1 && <RadioGroup ecId={`${this && this.props && this.props.ecId || ''}_RadioGroup@c3tbwe`} onChange={(e) => this.onRadioChange(e)} value={nowmonth}
                                                       style={{verticalAlign: "bottom"}}>
                                {monthdata && monthdata.length > 0 && monthdata.map((element, idx) => {
                                    return <RadioButton ecId={`${this && this.props && this.props.ecId || ''}_RadioButton@9vdes1@${element.label}`} value={element.label}>{element.value}</RadioButton>
                                })}
                            </RadioGroup>}
                            {type1 == 2 && <RadioGroup ecId={`${this && this.props && this.props.ecId || ''}_RadioGroup@9injl7`} onChange={(e) => this.onRadioChange(e)} value={nowseason}
                                                       style={{verticalAlign: "bottom"}}>
                                {seasondata && seasondata.length > 0 && seasondata.map((element, idx) => {
                                    return <RadioButton ecId={`${this && this.props && this.props.ecId || ''}_RadioButton@vzgdy2@${element.label}`} value={element.label}>{element.value}</RadioButton>
                                })}
                            </RadioGroup>}
                            {cstatus && <WeaTag ecId={`${this && this.props && this.props.ecId || ''}_WeaTag@lj0u2g`} color={ccolor} className="accessview-weatag">{cstatus}</WeaTag>}
                            <span dangerouslySetInnerHTML={{__html: pesronstr}}></span>
                        </div>
                        {msg == "1" ? <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@1lsajb`} height={agentmessage ? (_height - 152) : (_height - 120)}
                                                    style={{background: "#fff"}}>
                            {showtype &&
                            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@kudfo4`}
                                datas={topTab}
                                keyParam="viewcondition" //主键
                                selectedKey={tabkey}
                                buttons={this.getAllScore()}
                                onChange={val => this.setState({tabkey: val})}
                            />
                            }
                            <AccessViewTable ecId={`${this && this.props && this.props.ecId || ''}_AccessViewTable@qzqrvv`}
                                showtype={showtype}
                                ref={"accessTables"}
                                tabkey={tabkey}
                                onCallBack={this.doLastSubmit}/>

                            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@05ikae`} gutter={2} className="accessview-row">
                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@anfro0`} span={12}>
                                    {scoreid && scoreid.length > 0 && <AccessViewFb ecId={`${this && this.props && this.props.ecId || ''}_AccessViewFb@qy3ki6`}/>}
                                </Col>
                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@gu0l0r`} span={1}></Col>
                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@9jeyv9`} span={11}>
                                    <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@czg5ne`} title={getLabel('24969', '相关链接')} showGroup={true}>
                                        <div className="accessview-row-div-relate">
                                            <div className="accessview-row-col-linkurl"><a
                                                href={"/spa/blog/static/index.html#/user/" + resourceid} target="_blank"
                                                title={getLabel('509184', '{name}的工作微博').replace('{name}', resourcename)}>{getLabel('509184', '{name}的工作微博').replace('{name}', resourcename)}</a>
                                            </div>
                                            {isplan && <div className="accessview-row-col-linkurl"><a
                                                href={"/spa/workrelate/static/index.html#/main/workrelate/plan/planView?year=" + nowyear + "&type1=1&type2=" + type2 + "&resourceid=" + resourceid}
                                                target="_blank"
                                                title={getLabel(509323, '$name$的工作总结及计划').replace('$name$', resourcename) + "(" + nowyear + "-" + (type2 < 10 ? "0" + type2 : type2) + ")"}>{getLabel(509323, '$name$的工作总结及计划').replace('$name$', resourcename) + "(" + nowyear + "-" + (type2 < 10 ? "0" + type2 : type2) + ")"}</a>
                                            </div>}
                                            {linkUrlList && linkUrlList.length > 0 && linkUrlList.map((element, idx) => {
                                                return <div className="accessview-row-col-linkurl"><a
                                                    href={element.linkurl} target="_blank"
                                                    title={element.linkname}>{element.linkname}</a></div>
                                            })}
                                        </div>
                                    </WeaSearchGroup>
                                    {canlog && <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@upuk3p`} title={getLabel('32061', '操作日志')} showGroup={true}>
                                        <LoadLogs ecId={`${this && this.props && this.props.ecId || ''}_LoadLogs@xo55b3`} logsData={logList} lastcount={total} morename={morename}
                                                  moretitle={moretitle} onMoreClick={() => this.getMoreLog()}/>
                                    </WeaSearchGroup>}
                                </Col>
                            </Row>
                        </WeaNewScroll> : msg != "" ? Util.renderAlertPage('<span style="color:red">' + msg + '</span>', '', '30%','',this.props.ecId || '') : ""}
                    </WeaRightMenu>
                </Spin>
            </div>
        )
    }

    //获取总得分内容
    getAllScore = () => {
        const {datalist} = this.props.accessViewStore;
        return [<Popover ecId={`${this && this.props && this.props.ecId || ''}_Popover@xnzd6e@totalscore`}
            placement={"bottomLeft"}
            content={<div>{this.getPopoverContent()}</div>}
        >
         <span style={{"margin-right": "20px", "cursor": "pointer"}}>
           最终得分：
           <span style={{color: "red"}}>
             <b>
               {datalist.find(record => record.onlyid == 100).score_0}
             </b>
           </span>
         </span>
        </Popover>]
    }

    //获取气泡内容
    getPopoverContent = () => {
        const {tableHeader, datalist} = this.props.accessViewStore;
        return tableHeader.map((item,idx) => <div style={{"border-bottom": "1px solid rgba(224, 224, 224)"}}>
            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@4imemp@${idx}`}>
                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@01w4pe@${idx}`} span={18}>
                    {item.title + "："}
                </Col>
                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@a4hdw0@${idx}`} span={6}>
                    <span
                        style={{color: "red"}}><b>{datalist.find(record => record.onlyid == 5)["score_" + item.index]}</b></span>
                </Col>
            </Row>
        </div>)
    }

    getHeight(header) {
        let h = 0;
        if (header) {
            h = header.clientHeight || 0;
        }
        return window.innerHeight - h;
    }

    getAccessView(scoreid, resourceid, year, type1, type2) {
        const {accessViewStore} = this.props;
        let _this = this;
        accessViewStore.accessView({
            scoreid: scoreid, resourceid: resourceid, year: year, type1: type1, type2: type2, doback: function () {
                _this.doOtherOperation("init", getLabel('508895', '考核方案已变更，是否更新？'), getLabel('2022', '重置'));
            }
        });
    }

    onReqTop(key) {//顶部tab切换
        const {accessViewStore} = this.props;
        const {resourceid, nowyear} = accessViewStore;
        accessViewStore.type1 = key;
        let type2 = "";
        if (key == 1) {//月
            type2 = accessViewStore.nowmonth;
        } else if (key == 2) {
            type2 = accessViewStore.nowseason;
        }
        this.getAccessView("", resourceid, nowyear, key, type2);
    }

    yearChange(v) {//年下拉框变化
        const {accessViewStore} = this.props;
        const {resourceid, type1, type2} = accessViewStore;
        let _this = this;
        accessViewStore.accessView({
            resourceid: resourceid, type1: type1, year: v, type2: type2, doback: function () {
                _this.doOtherOperation("init", getLabel('508895', '考核方案已变更，是否更新？'), getLabel('2022', '重置'));
            }
        });
    }

    onRadioChange(e) {//Radio切换
        const {accessViewStore} = this.props;
        const {resourceid, type1, nowyear} = accessViewStore;
        let _this = this;
        accessViewStore.accessView({
            resourceid: resourceid, type1: type1, year: nowyear, type2: e.target.value, doback: function () {
                _this.doOtherOperation("init", getLabel('508895', '考核方案已变更，是否更新？'), getLabel('2022', '重置'));
            }
        });
    }

    getMoreLog() {//得到操作日志
        const {accessViewStore} = this.props;
        let _this = this;
        let _name = getLabel('82720', '加载更多');
        accessViewStore.getAccessLogInfo({
            doback: function () {
                _this.setState({morename: _name, moretitle: _name});
            }
        });
    }

    doOperation(type) {//保存提交
        const {accessViewStore} = this.props;
        if (type) {
            accessViewStore.currenttype = type;
        }
        if (type == "submit" && !this.checkMust()) {
            Modal.warning({
                title: getLabel('558', '提示'),
                content: getLabel('509185', '请完整填写考核分数;定量指标需填写目标值完成值及{titlestr}目标;有修正分时需填写修正理由').replace('{titlestr}', accessViewStore.titlestr)
            });
            return false;
        }
        if (type == "submit") {//提交时候需要判断必填值是否必填
            let _this = this;
            Modal.confirm({
                title: getLabel('131329', '信息确认'),
                content: getLabel('508894', '确定提交考核结果？'),
                onOk() {
                    _this.doSaveAndSubmit();
                },
                onCancel() {
                },
            });
        } else {
            this.doSaveAndSubmit();
        }
    }

    doSaveAndSubmit() {
        const {accessViewStore} = this.props;
        accessViewStore.loading = true;
        if (accessViewStore.uploading) {
            this.refs.accessTables.wrappedInstance.saveUpload();
        } else {
            this.doLastSubmit();
        }
    }

    doLastSubmit=()=> {
        const {accessViewStore} = this.props;
        let _this = this;
        accessViewStore.saveAccess({
            operation: accessViewStore.currenttype, doback: function (status) {
                if (status == 1) {
                    message.success(getLabel('30700', '操作成功'));
                    _this.doCallBackParent();
                } else if (status == 3) {
                    message.warning(getLabel('2012', '对不起，您暂时没有权限！'));
                } else if (status == 4) {
                    message.error(getLabel('21809', '保存失败，请重试！'));
                } else if (status == 6) {
                    message.error(getLabel(519388, '考核评分已变更，请重新评分！'));
                } else {
                    message.error(getLabel('30651', '操作失败'));
                }
            }
        });
    }

    //回调父窗口函数
    doCallBackParent() {
        if (window.opener) {
            if (typeof window.opener.RefreshAccessResultList === "function") {//考核成绩
                window.opener.RefreshAccessResultList();
            } else if (typeof window.opener.RefreshAccessAuditList === "function") {//考核评分
                window.opener.RefreshAccessAuditList();
            }
        }
    }

    doOtherOperation(type, content, info, isaudit) {
        const {accessViewStore} = this.props;
        let _this = this;
        Modal.confirm({
            title: getLabel('131329', '信息确认'),
            content: content,
            onOk() {
                accessViewStore.doOtherOperation({
                    operation: type, isaudit: isaudit, doback: function (status) {
                        if (status == 1) {
                            message.success(getLabel('30700', '操作成功'));
                            _this.doCallBackParent();
                        } else if (status == 3) {
                            message.warning(getLabel('2012', '对不起，您暂时没有权限！'));
                        } else {
                            message.error(getLabel('30651', '操作失败'));
                        }
                    }
                });
            },
            onCancel() {
            },
        });
    }

    doApproveAndReturn(type, content, info) {//批准和退回
        const {accessViewStore} = this.props;
        let _this = this;
        Modal.confirm({
            title: getLabel('131329', '信息确认'),
            content: content,
            onOk() {
                accessViewStore.doApproveAndReturn({
                    operation: type, doback: function (status, hasright) {
                        if (status) {
                            if (hasright) {
                                message.success(getLabel('30700', '操作成功'));
                                _this.doCallBackParent();
                            } else {
                                message.warning(getLabel('2012', '对不起，您暂时没有权限！'));
                            }
                        } else {
                            message.error(getLabel('30651', '操作失败'));
                        }
                    }
                });
            },
            onCancel() {
            },
        });
    }

    checkMust() {
        const {accessViewStore: {datalist, itemcount, tableHeader}} = this.props;
        const {tabkey} = this.state;
        let flag = true;
        let cidx = "";
        tableHeader.map((element, idx) => {
            let arr = datalist.filter((item, index) => index < itemcount && item.userid == element.userid);
            if (arr && arr.length == 0) {
                arr = datalist.filter((item, index) => (index < itemcount && item.userid == "") || index >= itemcount)
            }
            arr.map((record, index) => {
                if (record["edit_" + element.index] == 1) {
                    cidx = element.index;
                    if ((record.itemtype == 1 || (record.itemtype == 2 && (record.formula == 0 || record.formula == 4)))) {//定性指标
                        if (record['score_' + element.index] === "") { //定性类指标没有评分
                            flag = false;
                        }
                    } else {//定量指标没有填写完成值 目标值和下个周期目标值
                        if (record.itemtarget === "" || record.itemresult === "" || record.itemnext === "") {
                            flag = false;
                        }
                    }
                }
            })
        })
        datalist.map((record, index) => {
            if (index >= itemcount && record.onlyid == 2) {
                if (record["score_" + cidx] != 0 && record["reason" + cidx] === "") {
                    flag = false;
                }
            }
        });
        return flag;
    }

    //获取操作菜单
    getRightButton(type) {
        const {accessViewStore: {canback, canreset, canedit, caninit, canaudit, canrecover, canbackpre,canauditbackpre}} = this.props;
        let menu = [];
        let menu1 = [];
        if (canback) {//退回
            menu.push({
                key: '0', icon: <i className="icon-coms-go-back"/>, content: getLabel('236', '退回'),
                onClick: key => this.doOtherOperation("score_return", getLabel('508667', '确定退回此考核结果'), getLabel('508881', '退回此考核结果'))
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@npcuvr@scorereturn`} placement="bottomLeft" title={getLabel('508875', '退回考核结果')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2w3y47@scorereturn`}
                onClick={() => this.doOtherOperation("score_return", getLabel('508667', '确定退回此考核结果'), getLabel('508881', '退回此考核结果'))}>{getLabel('236', '退回')}</Button></Tooltip>);
        }
        if (canbackpre) {//退回上一级
            menu.push({
                key: '7', icon: <i className='icon-coms-huanhang'/>, content: getLabel('508880', '退回上一级'),
                onClick: key => this.doOtherOperation("return_pre", getLabel('508876', '确定退回此考核结果到上一个考核人?'), getLabel('508877', '退回此考核结果到上一个考核人'), 1)
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@0kic9s@returnpre`} placement="bottomLeft" title={getLabel('508883', '退回考核结果到上一个考核人')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@5mtzfp@returnpre`}
                onClick={() => this.doOtherOperation("return_pre", getLabel('508876', '确定退回此考核结果到上一个考核人?'), getLabel('508877', '退回此考核结果到上一个考核人'), 1)}>{getLabel('508880', '退回上一级')}</Button></Tooltip>);
        }
        if (canreset) {//重新考核
            menu.push({
                key: '1', icon: <i className='icon-coms-Reopen'/>, content: getLabel('508884', '重新考核'),
                onClick: key => this.doOtherOperation("reset", getLabel('508886', '确定重新进行考核评分？'), getLabel('508884', '重新考核'))
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@5bhk3p@resetscore`} placement="bottomLeft" title={getLabel(509458, '重新进行考核评分')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@13gd9z@resetscore`}
                onClick={() => this.doOtherOperation("reset", getLabel('508886', '确定重新进行考核评分？'), getLabel('508884', '重新考核'))}>{getLabel('508884', '重新考核')}</Button></Tooltip>);
        }
        if (caninit) {//重置
            menu.push({
                key: '2', icon: <i className='icon-coms-Forcible'/>, content: getLabel('2022', '重置'),
                onClick: key => this.doOtherOperation("init", getLabel('508887', '确定重置考核项及结果？'), getLabel('2022', '重置'))
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@b48e51@initscore`} placement="bottomLeft" title={getLabel('508888', '重置考核方案')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@0j28zt@initscore`}
                onClick={() => this.doOtherOperation("init", getLabel('508887', '确定重置考核项及结果？'), getLabel('2022', '重置'))}>{getLabel('2022', '重置')}</Button></Tooltip>);
        }
        if (canrecover) {
            menu.push({
                key: '8', icon: <i className="icon-coms-Reset"/>, content: getLabel('18666', '收回'),
                onClick: key => this.doOtherOperation("recover", getLabel('508889', '确定收回考核项及结果？'), getLabel('18666', '收回'))
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@t2gatc@recover`} placement="bottomLeft" title={getLabel('508890', '收回考核项及结果')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ylvpzt@recover`}
                onClick={() => this.doOtherOperation("recover", getLabel('508889', '确定收回考核项及结果？'), getLabel('18666', '收回'))}>{getLabel('18666', '收回')}</Button></Tooltip>);
        }
        if (canedit) {
            menu.push({
                key: '3', icon: <i className='icon-coms-Save-as'/>, content: getLabel('30986', '保存'),
                onClick: key => this.doOperation("save")
            });
            menu.push({
                key: '4', icon: <i className="icon-coms-Approval"/>, content: getLabel('615', '提交'),
                onClick: key => this.doOperation("submit")
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@vulri0@save`} placement="bottomLeft" title={getLabel('508724', '保存为草稿')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@6jvlmx@save`}
                onClick={() => this.doOperation("save")}>{getLabel('30986', '保存')}</Button></Tooltip>);
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@2kl76w@submit`} placement="bottomLeft" title={getLabel('382335', '保存并提交')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@u9jn22@submit`}
                onClick={() => this.doOperation("submit")}>{getLabel('615', '提交')}</Button></Tooltip>);
        }
        if (canaudit) {
            menu.push({
                key: '5', icon: <i className='icon-coms-Approval'/>, content: getLabel('142', '批准'),
                onClick: key => this.doApproveAndReturn("approve", getLabel('508666', '确定批准此考核结果'), getLabel('142', '批准'))
            });
            menu.push({
                key: '6', icon: <i className="icon-coms-go-back"/>, content: getLabel('236', '退回'),
                onClick: key => this.doApproveAndReturn("return", getLabel('508667', '确定退回此考核结果'), getLabel('236', '退回'))
            });
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@9lj7kq@approve`} placement="bottomLeft" title={getLabel('508874', '批准考核结果')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@h2cqm0@approve`}
                onClick={() => this.doApproveAndReturn("approve", getLabel('508666', '确定批准此考核结果'), getLabel('142', '批准'))}>{getLabel('142', '批准')}</Button></Tooltip>);
            menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@z38qd4@return`} placement="bottomLeft" title={getLabel('508875', '退回考核结果')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@n270ai@return`}
                onClick={() => this.doApproveAndReturn("return", getLabel('508667', '确定退回此考核结果'), getLabel('236', '退回'))}>{getLabel('236', '退回')}</Button></Tooltip>);
            if (canauditbackpre) {
                menu.push({
                    key: '7', icon: <i className='icon-coms-huanhang'/>, content: getLabel('508880', '退回上一级'),
                    onClick: key => this.doOtherOperation("return_pre", getLabel('508876', '确定退回此考核结果到上一个考核人?'), getLabel('508877', '退回此考核结果到上一个考核人'), 2)
                });
                menu1.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@6dm6j6@adiutreturnpre`} placement="bottomLeft" title={getLabel('508878', '退回到上一个考核人')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ukr4gm@adiutreturnpre`}
                    onClick={() => this.doOtherOperation("return_pre", getLabel('508876', '确定退回此考核结果到上一个考核人?'), getLabel('508877', '退回此考核结果到上一个考核人'), 2)}>{getLabel('508880', '退回上一级')} </Button></Tooltip>);
            }
        }
        if (type == 1) {
            return menu;
        } else {
            return menu1;
        }
    }

};